package com.alogic.auth.service;

import com.alogic.auth.PrincipalManager;
import com.alogic.auth.SessionManagerFactory;
import com.logicbus.backend.AbstractServant;
import com.logicbus.backend.Context;
import com.logicbus.backend.ServantException;
import com.logicbus.models.servant.ServiceDescription;


/**
 * 预登录服务
 */
public class PreLogin extends AbstractServant {

    @Override
    protected void onDestroy() {

    }

    @Override
    protected void onCreate(ServiceDescription sd) {

    }

    @Override
    protected int onJson(Context ctx){
        PrincipalManager sm = (PrincipalManager)SessionManagerFactory.getDefault();
        sm.prelogin(ctx);
        return 0;
    }

    @Override
    protected int onYaml(Context ctx){
        PrincipalManager sm = (PrincipalManager)SessionManagerFactory.getDefault();
        sm.prelogin(ctx);
        return 0;
    }


    @Override
    protected int onXml(Context ctx){
        throw new ServantException("core.e1000","Protocol XML is not suppurted.");
    }
}
